/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.service.impl;

import com.qdu.dao.BookDao;
import com.qdu.dao.impl.BookDaoImpl;
import com.qdu.entity.Book;
import com.qdu.service.BookService;
import java.util.List;

/**
 *
 * @author Lenovo
 */
public class BookServiceImpl implements BookService{
BookDao bookDao = new BookDaoImpl();
    @Override
    public List<Book> findAllBooks() {
        return bookDao.getAllBooks();
    }

    @Override
    public List<Book> findBooksByKeyword(String keyword) {
        return bookDao.getBooksByKeyword(keyword);
    }

    @Override
    public Book findBookById(String bookId) {
         Book book = bookDao.getBookInfoById(bookId);
         return book;
    }

    @Override
    public int registerNewBook(Book b) {
         Book book=bookDao.getBookInfoById(b.getbId());
        if(null==book){
            return bookDao.insert(b);
        }else{
            return -1;
        }
    }

    @Override
    public int modifyBookInfo(Book b) {
            return bookDao.update(b);
    }

    @Override
    public int unregister(String bId) {
         return bookDao.deleteBybId(bId);
    }
    
}
